//
//  XOWMNaviBar.m
//  XOWMSDK
//
//  Created by skyline on 2018/3/9.
//  Copyright © 2018年 skyline. All rights reserved.
//

#import "XOWMNaviBar.h"
@interface XOWMNaviBar()
@property (nonatomic, strong) XOWMCustomButton *backBtn;
@property (nonatomic, strong) XOWMLabel *titleLBL;
@property (nonatomic, strong) UIView *line;
@end
@implementation XOWMNaviBar
- (instancetype)init
{
    self = [super init];
    if (self)
    {
        self.backBtn.hidden = NO;
        self.line.hidden = NO;
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (XOWMCustomButton *)backBtn
{
    if (!_backBtn)
    {
        _backBtn = [[XOWMCustomButton alloc]initWithBackIMG:@"back"];
        [_backBtn addTarget:self action:@selector(yjd_actionForBackButton) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_backBtn];
        _backBtn.c_left.equal(self).with.coffset(5);
        _backBtn.c_top.equal(self).with.coffset(5);
        _backBtn.c_size.equal(CGSizeMake(BUTTONHEIGHT - 14, BUTTONHEIGHT - 14));
    }
    return _backBtn;
}

- (XOWMLabel *)titleLBL
{
    if (!_titleLBL)
    {
        _titleLBL = [[XOWMLabel alloc] init];
        _titleLBL.font = [UIFont systemFontOfSize:15];
        _titleLBL.textColor = TEXT_BLACK_COLOR;
        [self addSubview:_titleLBL];
        _titleLBL.c_center.equal(self);
    }
    return _titleLBL;
}

- (UIView *)line
{
    if (!_line)
    {
        _line = [[UIView alloc] init];
        _line.backgroundColor = CELL_LINE_COLOR;
        [self addSubview:_line];
        _line.c_left.equal(self);
        _line.c_right.equal(self);
        _line.c_bottom.equal(self.c_bottom);
        _line.c_height.equal(1);
    }
    return _line;
}

- (void)setTitle:(NSString *)title
{
    if (_title != title)
    {
        _title = title;
        self.titleLBL.text = _title;
    }
}

- (void)yjd_actionForBackButton
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(yjd_methodForNaviBarDelegate)])
    {
        [self.delegate yjd_methodForNaviBarDelegate];
    }
}

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */


- (void)sp_getMediaFailed {
    NSLog(@"Get User Succrss");
}
@end
